﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MessageQuque.Common;

namespace MessageQuque
{
    /// <summary>
    /// 获取RabbitMQ配置项
    /// </summary>
    public static class Config
    {
        /// <summary>
        /// rabbitmq-server地址（基于amqp协议)
        /// </summary>
        public static string UriAddress
        {
            get { return string.Format("amqp://{0}:{1}/", ConfigurationManager.AppSettings.Get("server"), ConfigurationManager.AppSettings.Get("port")); }
        }

        /// <summary>
        /// 服务器
        /// </summary>
        public static string Server
        {
            get { return ConfigurationManager.AppSettings.Get("server"); }
        }

        /// <summary>
        /// 端口
        /// </summary>
        public static int Port
        {
            get { return ConfigurationManager.AppSettings.Get("port").CastTo<int>(); }
        }

        /// <summary>
        /// 用户名
        /// </summary>
        public static string UserName
        {
            get { return ConfigurationManager.AppSettings.Get("username"); }
        }

        /// <summary>
        /// 密码
        /// </summary>
        public static string Password
        {
            get { return ConfigurationManager.AppSettings.Get("password"); }
        }

        /// <summary>
        /// 虚拟主机名称
        /// </summary>
        public static string VirtualHost
        {
            get { return ConfigurationManager.AppSettings.Get("virtualHost"); }
        }

        /// <summary>
        /// protocol
        /// </summary>
        public static string Protocol
        {
            get { return ConfigurationManager.AppSettings.Get("protocol"); }
        }

        /// <summary>
        /// 最大队列数
        /// </summary>
        public static long MaxSize
        {
            get { return ConfigurationManager.AppSettings.Get("maxSize").CastTo<long>(); }
        }

        /// <summary>
        /// 是否对消息持久化保存
        /// </summary>
        public static bool PersistMode
        {
            get { return true; }
        }
    }
}
